﻿using DotNetMVC.OA.IBLL;
using DotNetMVC.OA.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DotNetMVC.OA.BLL
{
 public partial class RoleInfoService : BaseService<RoleInfo>, IRoleInfoService
    {
        public IQueryable<RoleInfo> LoagPageData(Model.Param.RoleQueryParam roleQueryParam)
        {
            short normalFlag = (short)Model.Enum.DelFlagEnum.Normal;
            var temp = DbSession.RoleInfoDal.GetEntities(u=>u.DelFlag== normalFlag);

            //过滤角色
            if (!string.IsNullOrEmpty(roleQueryParam.SchName))
            {
                temp=temp.Where(u=>u.RoleName.Contains(roleQueryParam.SchName));
            }
            //过滤备注
            if (!string.IsNullOrEmpty(roleQueryParam.SchRemark))
            {
                temp = temp.Where(u => u.Remark.Contains(roleQueryParam.SchRemark));
            }
            roleQueryParam.Total = temp.Count();
            //分页
            return temp.OrderBy(u => u.ID)
                .Skip(roleQueryParam.PageSize * (roleQueryParam.PageIndex - 1))
                .Take(roleQueryParam.PageSize);

        }
    }
}
